mruby 4.0.0
mruby is the lightweight implementation of the Ruby language
Loading...
Searching...
No Matches
mrbconf.h
1/*
2** mrbconf.h - mruby core configuration
3**
4** See Copyright Notice in mruby.h
5*/
6
7#ifndef MRUBYCONF_H
8#define MRUBYCONF_H
9
10/* architecture selection: */
11/* specify -DMRB_32BIT or -DMRB_64BIT to override */
12#if !defined(MRB_32BIT) && !defined(MRB_64BIT)
13#if UINT64_MAX == SIZE_MAX
14#define MRB_64BIT
15#else
16#define MRB_32BIT
17#endif
18#endif
19
20#if defined(MRB_32BIT) && defined(MRB_64BIT)
21#error Cannot build for 32 and 64-bit architecture at the same time
22#endif
23
24/* configuration options: */
25/* add -DMRB_USE_FLOAT32 to use float instead of double for floating-point numbers */
26//#define MRB_USE_FLOAT32
27
28/* exclude floating-point numbers */
29//#define MRB_NO_FLOAT
30
31/* obsolete configuration */
32#if defined(MRB_USE_FLOAT)
33# define MRB_USE_FLOAT32
34#endif
35
36/* obsolete configuration */
37#if defined(MRB_WITHOUT_FLOAT)
38# define MRB_NO_FLOAT
39#endif
40
41#if defined(MRB_USE_FLOAT32) && defined(MRB_NO_FLOAT)
42#error Cannot define MRB_USE_FLOAT32 and MRB_NO_FLOAT at the same time
43#endif
44
45/* define on big endian machines; used by MRB_NAN_BOXING, etc. */
46#ifndef MRB_ENDIAN_BIG
47# if (defined(BYTE_ORDER) && defined(BIG_ENDIAN) && BYTE_ORDER == BIG_ENDIAN) || \
48 (defined(__BYTE_ORDER__) && defined(__ORDER_BIG_ENDIAN__) && __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__)
49# define MRB_ENDIAN_BIG
50# endif
51#endif
52
53/* represent mrb_value in boxed double; conflict with MRB_USE_FLOAT32 and MRB_NO_FLOAT */
54//#define MRB_NAN_BOXING
55
56/* represent mrb_value as a word (natural unit of data for the processor) */
57//#define MRB_WORD_BOXING
58
59/* represent mrb_value as a struct; occupies 2 words */
60//#define MRB_NO_BOXING
61
62/* if no specific boxing type is chosen */
63#if !defined(MRB_NAN_BOXING) && !defined(MRB_WORD_BOXING) && !defined(MRB_NO_BOXING)
64# define MRB_WORD_BOXING
65#endif
66
67/* if defined mruby does not inline float values in word boxing;
68 all floats are heap-allocated as RFloat objects */
69//#define MRB_WORDBOX_NO_INLINE_FLOAT
70
71/* obsolete configuration */
72#if defined(MRB_WORDBOX_NO_FLOAT_TRUNCATE)
73# define MRB_WORDBOX_NO_INLINE_FLOAT
74#endif
75
76/* add -DMRB_INT32 to use 32-bit integer for mrb_int; conflict with MRB_INT64;
77 Default for 32-bit CPU mode. */
78//#define MRB_INT32
79
80/* add -DMRB_INT64 to use 64-bit integer for mrb_int; conflict with MRB_INT32;
81 Default for 64-bit CPU mode (unless using MRB_NAN_BOXING). */
82//#define MRB_INT64
83
84/* if no specific integer type is chosen */
85#if !defined(MRB_INT32) && !defined(MRB_INT64)
86# if defined(MRB_64BIT) && !defined(MRB_NAN_BOXING)
87/* Use 64-bit integers on 64-bit architecture (without MRB_NAN_BOXING) */
88# define MRB_INT64
89# else
90/* Otherwise use 32-bit integers */
91# define MRB_INT32
92# endif
93#endif
94
95/* MRB_INT64 on 32-bit with word/NaN boxing causes alignment issues
96 for heap-allocated RInteger (int64_t needs 8-byte alignment but
97 GC heap slots may not guarantee it); use MRB_NO_BOXING instead */
98#if defined(MRB_INT64) && defined(MRB_32BIT) && !defined(MRB_NO_BOXING)
99#error "MRB_INT64 on 32-bit requires MRB_NO_BOXING"
100#endif
101
102/* call malloc_trim(0) from mrb_full_gc() */
103//#define MRB_USE_MALLOC_TRIM
104
105/* string class to handle UTF-8 encoding */
106//#define MRB_UTF8_STRING
107
108/* maximum length of strings */
109/* the default value is 1MB */
110/* set this value to zero to skip the check */
111//#define MRB_STR_LENGTH_MAX 1048576
112
113/* maximum length of arrays */
114/* the default value is 2**17 entries */
115/* set this value to zero to skip the check */
116//#define MRB_ARY_LENGTH_MAX 131072
117
118/* argv max size in mrb_funcall */
119//#define MRB_FUNCALL_ARGC_MAX 16
120
121/* number of object per heap page */
122//#define MRB_HEAP_PAGE_SIZE 1024
123
124/* define if your platform does not support etext, edata */
125//#define MRB_NO_DEFAULT_RO_DATA_P
126
127/* define if your platform supports etext, edata */
128//#define MRB_USE_RO_DATA_P_ETEXT
129/* use MRB_USE_ETEXT_RO_DATA_P by default on Linux */
130#if (defined(__linux__) && !defined(__KERNEL__))
131#define MRB_USE_ETEXT_RO_DATA_P
132#endif
133
134/* you can provide and use mrb_ro_data_p() for your platform.
135 prototype is `mrb_bool mrb_ro_data_p(const char *ptr)` */
136//#define MRB_USE_CUSTOM_RO_DATA_P
137
138/* turn off generational GC by default */
139//#define MRB_GC_TURN_OFF_GENERATIONAL
140
141/* initial size of khash table bucket */
142//#define KHASH_INITIAL_SIZE 32
143
144/* allocated memory address alignment */
145//#define POOL_ALIGNMENT 4
146
147/* page size of memory pool */
148//#define POOL_PAGE_SIZE 16000
149
150/* arena size */
151//#define MRB_GC_ARENA_SIZE 100
152
153/* fixed size GC arena */
154//#define MRB_GC_FIXED_ARENA
155
156/* state atexit stack size */
157//#define MRB_FIXED_STATE_ATEXIT_STACK_SIZE 5
158
159/* fixed size state atexit stack */
160//#define MRB_FIXED_STATE_ATEXIT_STACK
161
162/* -DMRB_NO_XXXX to drop following features */
163//#define MRB_NO_STDIO /* use of stdio */
164
165/* -DMRB_USE_XXXX to enable following features */
166//#define MRB_USE_DEBUG_HOOK /* hooks for debugger */
167//#define MRB_USE_ALL_SYMBOLS /* Symbol.all_symbols */
168
169/* Symbol table configuration */
170/* Threshold for switching from linear search to hash table */
171#ifndef MRB_SYMBOL_LINEAR_THRESHOLD
172#define MRB_SYMBOL_LINEAR_THRESHOLD 256
173#endif
174
175/* Maximum number of dynamic symbols (created at runtime via to_sym etc.)
176 Presyms, inline symbols, and mrb_intern_static symbols are excluded.
177 Set to 0 to disable the limit. */
178#ifndef MRB_SYMBOL_MAX
179#define MRB_SYMBOL_MAX 4096
180#endif
181
182/* obsolete configurations */
183#if defined(DISABLE_STDIO) || defined(MRB_DISABLE_STDIO)
184# define MRB_NO_STDIO
185#endif
186#if defined(MRB_DISABLE_DIRECT_THREADING) || defined(MRB_NO_DIRECT_THREADING)
187# define MRB_USE_VM_SWITCH_DISPATCH
188#endif
189#if defined(ENABLE_DEBUG) || defined(MRB_ENABLE_DEBUG_HOOK)
190# define MRB_USE_DEBUG_HOOK
191#endif
192#ifdef MRB_ENABLE_ALL_SYMBOLS
193# define MRB_USE_ALL_SYMBOLS
194#endif
195#ifdef MRB_ENABLE_CXX_ABI
196# define MRB_USE_CXX_ABI
197#endif
198#ifdef MRB_ENABLE_CXX_EXCEPTION
199# define MRB_USE_CXX_EXCEPTION
200#endif
201
202/* end of configuration */
203
204#ifndef MRB_NO_STDIO
205# include <stdio.h>
206#endif
207
208/*
209** mruby tuning profiles
210**/
211
212/* A profile for micro controllers */
213#if defined(MRB_CONSTRAINED_BASELINE_PROFILE)
214# ifndef MRB_NO_METHOD_CACHE
215# define MRB_NO_METHOD_CACHE
216# endif
217
218# ifndef KHASH_INITIAL_SIZE
219# define KHASH_INITIAL_SIZE 16
220# endif
221
222# ifndef MRB_HEAP_PAGE_SIZE
223# define MRB_HEAP_PAGE_SIZE 256
224# endif
225
226/* A profile for default mruby */
227#elif defined(MRB_BASELINE_PROFILE)
228
229/* A profile for desktop computers or workstations; rich memory! */
230#elif defined(MRB_MAIN_PROFILE)
231# ifndef MRB_METHOD_CACHE_SIZE
232# define MRB_METHOD_CACHE_SIZE (1<<10)
233# endif
234
235# ifndef MRB_HEAP_PAGE_SIZE
236# define MRB_HEAP_PAGE_SIZE 4096
237# endif
238
239/* A profile for server; mruby vm is long life */
240#elif defined(MRB_HIGH_PROFILE)
241# ifndef MRB_METHOD_CACHE_SIZE
242# define MRB_METHOD_CACHE_SIZE (1<<12)
243# endif
244
245# ifndef MRB_HEAP_PAGE_SIZE
246# define MRB_HEAP_PAGE_SIZE 4096
247# endif
248#endif
249
250#endif /* MRUBYCONF_H */